package gui;

import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import common.Constants;
import common.EarthSimSettings;

public class InvocationSettingsPanel extends JPanel {
  private static final long serialVersionUID = -344890635170823703L;
  EarthSimSettings settings = EarthSimSettings.getInstance();
  
  public InvocationSettingsPanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createTitledBorder("Invocation Settings"));
    
    Dimension dim = new Dimension(145,90);
    setPreferredSize(dim);
    setMaximumSize(dim);
    
    add(getFormattedLabel(Constants.PRECISION, "Precision", (settings.getPrecision() == -1 ? "default" : String.valueOf(settings.getPrecision()))) );
    add(getFormattedLabel(Constants.SAMPLING_RATE, "Sampling Rate", String.valueOf(settings.getSamplingRate())));
    add(getFormattedLabel(Constants.TEMPORAL_ACCURACY, "Accuracy", String.valueOf(settings.getTemporalAccuracy())));
  }
  
  private JLabel getFormattedLabel(String flag, String flagDesc, String flagValue) {
    return new JLabel("<html><b><font size=small>" + flagDesc + " ("+ flag + "): </font></b>" + flagValue +"</html>");
  }  
}
